﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Jocker;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.Login
{
    public class LoginCreateHandlerL : IRequestHandler<LoginCreateCommond, ResultsDTO>
    {


        private readonly IBateRepository<RecordsLogin> _RecordsLogin;


        public LoginCreateHandlerL(IBateRepository<RecordsLogin> recordsLogin)
        {
            _RecordsLogin = recordsLogin;

        }

        public async Task<ResultsDTO> Handle(LoginCreateCommond request, CancellationToken cancellationToken)
        {
            try
            {
                var list = new ResultsDTO() { Code = 0 };

                var per = new RecordsLogin()
                {
                    Logsid = request.Logsid,
                    OperatorName = request.OperatorName,
                    OperatorTime = request.OperatorTime,
                    PerformOperation = request.PerformOperation,
                };
                DapperHelper dapperHelper = new DapperHelper();
                string str = "insert login values(@Logsid,@OperatorName,@OperatorTime,@PerformOperation)";
             var koh=  await  _RecordsLogin.Add(str, per, dapperHelper.MangoMesWrite);
                if(koh!=null)
                {

                    list.Code = 1;
                    list.Message = "日志添加成功";

                }
                return list;

            }
            catch (Exception)
            {

                throw;
            }
          





        }
    }
}
